<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('薪资变动纠错添加员工')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form" AUTOCOMPLETE="OFF">
                    <div class="select-list">
                        <ul>
                            <li>
                                工号：<input type="text" name="badge"/>
                            </li>
                            <li>
                                姓名：<input type="text" name="name"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>
<th:block th:include="include :: datetimepicker-js"/>


<script th:inline="javascript">
    var prefix = ctx + "salaryChange/salaryChange";
    var pgid;
    var Bgdate;
    var EDdate;

    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        var map = [[${map}]];
        pgid = map.id;
        Bgdate = map.Bgdate;
        EDdate = map.EDdate;

        getData();
    });

    function getData() {
        var options = {
            code: "id",
            uniqueId: "id",
            pagination: false,
            url: prefix + "/findDataHistory?pgid=" + pgid + "&Bgdate=" + Bgdate + "&EDdate=" + EDdate,
            height: $(window).height() - 120,
            modalName: "薪资变动纠错添加员工",
            columns: [
                [
                    {
                        checkbox: true,
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'badge', title: '工号',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'name', title: '姓名',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'compName', title: '公司名称',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'depName', title: '部门名称',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'jobName', title: '工作岗位',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'empStatusName', title: '员工状态',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'pzidName', title: '薪资区域',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'effectdate', title: '生效日期',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'regtime', title: '登记时间',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'regbyName', title: '登记人',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'initialized', title: '？确认',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'initializedbyName', title: '确认人',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'initialiZedTime', title: '确认时间',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'closed', title: '？封存',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'closedByName', title: '封存人',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'closedTime', title: '封存时间',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'remark', title: '备注',
                        rowspan: 2,
                        valign: "middle"
                    },
                ],
                [],
            ]
        };

        //利用ajax动态获取项目
        $.ajax({
            async: false,
            url: ctx + "salaryAdmin/findProObject",
            data: {
                "pgid": pgid
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                for (var i = 0; i < data.length; i++) {
                    var text = data[i].title.replace('（', '').replace("）", '');
                    var stdId = data[i].id;
                    var field = text + "@@@" + stdId;
                    options.columns[0].push({
                        title: data[i].title,
                        rowspan: 1,
                        colspan: 2,
                        align: "center"
                    });
                    options.columns[1].push({
                        title: '原数值',
                        rowspan: 1,
                        field: field + "@@@旧"
                    });
                    options.columns[1].push({
                        title: '数值',
                        rowspan: 1,
                        field: field + "@@@新", editable: true
                    });
                }

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
        $.table.init(options);
    }

    function submitHandler() {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        var num = 0;
        var allid = "";
        if (row.length == 0) {
            $.modal.alertWarning("请选择需要调岗的人员");
            return;
        }
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allid += row[i].id
            } else {
                allid += row[i].id + ","
            }
        }
        $.ajax({
            url: ctx + "SalaryChangeCorrection/SalaryChangeCorrection/changeAdd2",
            data: {
                "allid": allid
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                $.operate.successCallback(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }
</script>
</body>
</html>